<template>
  <div class="my_div">
    <img :src="item.dogImgUrl" />
    <p :style="{ backgroundColor: colorStr }" @click="btn(item.dogName)">
      {{ item.dogName }}
    </p>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      colorStr: "",
    };
  },
  methods: {
    btn(dogName) {
      this.colorStr = `rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)}, ${Math.random()})`;
      // this.$emit("love", dogName);
      this.$emit("love", this.item.dogName);
    },
  },
};
</script>

<style>
.my_div {
  width: 400px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
}
</style>